﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace JT808Gateway.Data
{
    public interface IBaseRepository<TEntity> where TEntity : class
    {
        #region 根据主键Id获取实体数据

        /// <summary>
        /// 根据主键Id获取实体数据
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="objId">主键Id</param>
        /// <returns>返回表数据实体</returns>
        TEntity GetById(object objId, string tableName = null);

        /// <summary>
        /// 根据主键Id获取实体数据
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="objId">主键Id</param>
        /// <returns>返回表数据实体</returns>
        Task<TEntity> GetByIdAsync(object objId, string tableName = null);

        /// <summary>
        /// 根据主键Id获取实体数据
        /// </summary>
        /// <typeparam name="TResult">返回结果类型</typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="objId">主键Id</param>
        /// <returns>返回指定结构实体数据</returns>
        TResult GetById<TResult>(object objId, string tableName = null);

        /// <summary>
        /// 根据主键Id获取实体数据
        /// </summary>
        /// <typeparam name="TResult">返回结果类型</typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="objId">主键Id</param>
        /// <returns>返回指定结构实体数据</returns>
        Task<TResult> GetByIdAsync<TResult>(object objId, string tableName = null);

        #endregion 根据主键Id获取实体数据

        #region 根据主键Id数组获取数据列表

        /// <summary>
        /// 根据ID数组查询数据
        /// </summary>
        /// <param name="lstIds">id列表（必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]），如果是联合主键，请使用Where条件</param>
        /// <param name="tableName">表名称</param>
        /// <returns>数据实体列表</returns>
        List<TEntity> GetByIDs(int[] lstIds, string tableName = null);

        /// <summary>
        /// 根据ID数组查询数据
        /// </summary>
        /// <param name="lstIds">id列表（必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]），如果是联合主键，请使用Where条件</param>
        /// <param name="tableName">表名称</param>
        /// <returns>数据实体列表</returns>
        Task<List<TEntity>> GetByIDsAsync(int[] lstIds, string tableName = null);

        /// <summary>
        /// 根据ID数组查询数据
        /// </summary>
        /// <param name="lstIds">id列表（必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]），如果是联合主键，请使用Where条件</param>
        /// <param name="tableName">表名称</param>
        /// <returns>数据实体列表</returns>
        List<TResult> GetByIDs<TResult>(int[] lstIds, string tableName = null);

        /// <summary>
        /// 根据ID数组查询数据
        /// </summary>
        /// <param name="lstIds">id列表（必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]），如果是联合主键，请使用Where条件</param>
        /// <param name="tableName">表名称</param>
        /// <returns>数据实体列表</returns>
        Task<List<TResult>> GetByIDsAsync<TResult>(int[] lstIds, string tableName = null);

        #endregion 根据主键Id数组获取数据列表

        #region 单实体新增数据到db

        /// <summary>
        /// 写入实体数据
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="entity">实体类</param>
        /// <returns></returns>
        bool Insert(TEntity entity, string tableName = null);

        /// <summary>
        /// 写入实体数据
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="entity">实体类</param>
        /// <returns></returns>
        Task<bool> InsertAsync(TEntity entity, string tableName = null);

        /// <summary>
        /// 写入实体数据 返回自增Id
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="entity">实体类</param>
        /// <returns></returns>
        int InsertReturnIdentity(TEntity entity, string tableName = null);

        /// <summary>
        ///  写入实体数据 返回自增Id
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="entity">实体类</param>
        /// <returns></returns>
        Task<int> InsertReturnIdentityAsync(TEntity entity, string tableName = null);

        /// <summary>
        /// 写入实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="tableName">表名称</param>
        /// <param name="insertColumns">指定只插入列</param>
        /// <returns>返回自增量列</returns>
        int InsertReturnIdentity(TEntity entity, Expression<Func<TEntity, object>> insertColumns = null);

        /// <summary>
        /// 写入实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="tableName">表名称</param>
        /// <param name="insertColumns">指定只插入列</param>
        /// <returns>返回自增量列</returns>
        int InsertReturnIdentity(string tableName, TEntity entity, Expression<Func<TEntity, object>> insertColumns = null);

        /// <summary>
        /// 写入实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="tableName">表名称</param>
        /// <param name="insertColumns">指定只插入列</param>
        /// <returns>返回自增量列</returns>
        Task<int> InsertReturnIdentityAsync(TEntity entity, Expression<Func<TEntity, object>> insertColumns = null);

        /// <summary>
        /// 写入实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="tableName">表名称</param>
        /// <param name="insertColumns">指定只插入列</param>
        /// <returns>返回自增量列</returns>
        Task<int> InsertReturnIdentityAsync(string tableName, TEntity entity, Expression<Func<TEntity, object>> insertColumns = null);

        #endregion 单实体新增数据到db

        #region 单实体编辑数据到db

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        bool Update(TEntity entity, string tableName = null);

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <returns></returns>
        Task<bool> UpdateAsync(TEntity entity, string tableName = null);

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="strSql">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        bool Update(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="strSql">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        Task<bool> UpdateAsync(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="lstColumns">更新的字段</param>
        /// <param name="lstIgnoreColumns">忽略的字段</param>
        /// <param name="strWhere">检索条件</param>
        /// <returns></returns>
        bool Update(TEntity entity, List<string> lstColumns, List<string> lstIgnoreColumns = null, string strWhere = "");

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="lstColumns">更新的字段</param>
        /// <param name="lstIgnoreColumns">忽略的字段</param>
        /// <param name="tableName">表名称</param>
        /// <param name="strWhere">检索条件</param>
        /// <returns></returns>
        bool Update(string tableName, TEntity entity, List<string> lstColumns, List<string> lstIgnoreColumns = null, string strWhere = "");

        /// <summary>
        /// 更新数据(lambda表达式，非实体)
        /// </summary>
        /// <param name="updateExpression">更新值表达式</param>
        /// <param name="whereExpression">检索表达式</param>
        /// <returns></returns>
        bool Update(Expression<Func<TEntity, bool>> updateExpression, Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="lstColumns">更新的字段</param>
        /// <param name="lstIgnoreColumns">忽略的字段</param>
        /// <param name="tableName">表名称</param>
        /// <param name="strWhere">检索条件</param>
        /// <returns></returns>
        Task<bool> UpdateAsync(TEntity entity, List<string> lstColumns, List<string> lstIgnoreColumns = null, string strWhere = "");

        /// <summary>
        /// 更新实体数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="lstColumns">更新的字段</param>
        /// <param name="lstIgnoreColumns">忽略的字段</param>
        /// <param name="tableName">表名称</param>
        /// <param name="strWhere">检索条件</param>
        /// <returns></returns>
        Task<bool> UpdateAsync(string tableName, TEntity entity, List<string> lstColumns, List<string> lstIgnoreColumns = null, string strWhere = "");

        #endregion 单实体编辑数据到db

        #region 单实体保存数据到db

        /// <summary>
        /// 保存实体数据
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        bool Save(TEntity entity);

        #endregion 单实体保存数据到db

        #region 单实体删除

        /// <summary>
        /// 根据实体删除一条数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        bool Delete(TEntity entity, string tableName = null);

        /// <summary>
        /// 根据实体删除一条数据
        /// </summary>
        /// <param name="entity">实体类</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        Task<bool> DeleteAsync(TEntity entity, string tableName = null);

        /// <summary>
        /// 删除指定ID的数据
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        bool DeleteById(object id, string tableName = null);

        /// <summary>
        /// 删除指定ID的数据
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        Task<bool> DeleteByIdAsync(object id, string tableName = null);

        /// <summary>
        /// 删除指定ID集合的数据(批量删除)
        /// </summary>
        /// <param name="ids">主键ID集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        bool DeleteByIds(object[] ids, string tableName = null);

        /// <summary>
        /// 删除指定ID集合的数据(批量删除)
        /// </summary>
        /// <param name="ids">主键ID集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        Task<bool> DeleteByIdsAsync(object[] ids, string tableName = null);

        /// <summary>
        /// 删除指定属性匹配的数据
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        bool DeleteBy(Expression<Func<TEntity, bool>> expression, string tableName = null);

        /// <summary>
        /// 删除指定属性匹配的数据
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        Task<bool> DeleteByAsync(Expression<Func<TEntity, bool>> expression, string tableName = null);

        #endregion 单实体删除

        #region 批量新增数据到db

        /// <summary>
        /// 事务-批量插入实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        bool InsertBatch(List<TEntity> listEntity, string tableName = null);

        /// <summary>
        /// 事务-批量插入实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        Task<bool> InsertBatchAsync(List<TEntity> listEntity, string tableName = null);

        /// <summary>
        /// 事务-批量插入实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        bool InsertBatchTran(List<TEntity> listEntity, string tableName = null);

        /// <summary>
        /// 事务-批量插入实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        Task<bool> InsertBatchTranAsync(List<TEntity> listEntity, string tableName = null);

        #endregion 批量新增数据到db

        #region 批量编辑数据到db

        /// <summary>
        /// 批量更新实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        bool UpdateBatch(List<TEntity> listEntity, string tableName = null);

        /// <summary>
        /// 批量更新实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        Task<bool> UpdateBatchAsync(List<TEntity> listEntity, string tableName = null);

        /// <summary>
        /// 事务-批量修改实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        bool UpdateBatchTran(List<TEntity> listEntity, string tableName = null);

        /// <summary>
        /// 事务-批量插入实体(速度快)
        /// </summary>
        /// <param name="listEntity">实体集合</param>
        /// <param name="tableName">表名称</param>
        /// <returns>影响行数</returns>
        Task<bool> UpdateBatchTranAsync(List<TEntity> listEntity, string tableName = null);

        #endregion 批量编辑数据到db

        #region 判断数据是否存在

        /// <summary>
        /// 查询数据是否存在
        /// </summary>
        /// <param name="whereExpression">检索表达式</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        bool GetExist(Expression<Func<TEntity, bool>> whereExpression, string tableName = null);

        /// <summary>
        /// 查询数据是否存在
        /// </summary>
        /// <param name="whereExpression">whereExpression</param>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        Task<bool> GetExistAsync(Expression<Func<TEntity, bool>> whereExpression, string tableName = null);

        #endregion 判断数据是否存在

        #region 获取单个实体

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        TEntity QuerySingle(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        Task<TEntity> QuerySingleAsync(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        TEntity QuerySingle(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        Task<TEntity> QuerySingleAsync(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        TResult QuerySingle<TResult>(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        Task<TResult> QuerySingleAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        TResult QuerySingle<TResult>(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        ///根据指定条件查询结果实体
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序规则</param>
        /// <returns></returns>
        Task<TResult> QuerySingleAsync<TResult>(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds = null);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>泛型集合</returns>
        TEntity QuerySqlQuerySingle(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>泛型集合</returns>
        Task<TEntity> QuerySqlQuerySingleAsync(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>泛型集合</returns>
        TResult QuerySqlQuerySingle<TResult>(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>泛型集合</returns>
        Task<TResult> QuerySqlQuerySingleAsync<TResult>(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        ///查询-2表查询返回结果实体
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体2</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <returns>值</returns>
        TResult QueryMuchEntity<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null, string strOrderByFileds = null) where T : class, new();

        /// <summary>
        ///查询-2表查询返回结果实体
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体2</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <returns>值</returns>
        Task<TResult> QueryMuchEntityAsync<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null) where T : class, new();

        ///  <summary>
        /// 查询-2表查询返回结果实体
        ///  </summary>
        ///  <typeparam name="T">实体1</typeparam>
        ///  <typeparam name="T2">实体2</typeparam>
        ///  <typeparam name="TResult">返回对象</typeparam>
        ///  <param name="tableName">表名称</param>
        ///  <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        ///  <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        ///  <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        ///  <returns>值</returns>
        TResult QueryMuchEntity<T, T2, TResult>(string tableName, Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null) where T : class, new();

        ///  <summary>
        /// 查询-2表查询返回结果实体
        ///  </summary>
        ///  <typeparam name="T">实体1</typeparam>
        ///  <typeparam name="T2">实体2</typeparam>
        ///  <typeparam name="TResult">返回对象</typeparam>
        ///  <param name="tableName">表名称</param>
        ///  <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        ///  <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        ///  <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        ///  <returns>值</returns>
        Task<TResult> QueryMuchEntityAsync<T, T2, TResult>(string tableName, Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null) where T : class, new();

        ///// <summary>
        /////查询-4表查询返回结果实体
        ///// </summary>
        ///// <typeparam name="T">实体1</typeparam>
        ///// <typeparam name="T2">实体2</typeparam>
        ///// <typeparam name="T3">实体3</typeparam>
        ///// <typeparam name="T4">实体4</typeparam>
        ///// <typeparam name="TResult">返回对象</typeparam>
        ///// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        ///// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        ///// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        ///// <returns>值</returns>
        //TResult QueryMuchEntity<T, T2, T3, T4, TResult>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression, Expression<Func<T, T2, T3, T4, TResult>> selectExpression, Expression<Func<T, T2, T3, T4, bool>> whereLambda = null, string strOrderByFileds = null) where T : class, new();

        #endregion 获取单个实体

        #region 查询列表

        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <returns>数据列表</returns>
        List<TEntity> Query();

        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync();

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string strWhere);

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string strWhere);

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>数据列表</returns>
        List<TResult> Query<TResult>(string strWhere);

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>数据列表</returns>
        Task<List<TResult>> QueryAsync<TResult>(string strWhere);

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 按照特定列查询数据列表
        /// </summary>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        List<TResult> Query<TResult>(Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 按照特定列查询数据列表
        /// </summary>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        Task<List<TResult>> QueryAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string tableName, Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string tableName, Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 按照特定列查询数据列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        List<TResult> Query<TResult>(string tableName, Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 按照特定列查询数据列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">whereExpression</param>
        /// <returns>数据列表</returns>
        Task<List<TResult>> QueryAsync<TResult>(string tableName, Expression<Func<TEntity, bool>> whereExpression);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <param name="whereExpression">whereExpression</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns>数据列表</returns>
        List<TResult> Query<TResult>(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">whereExpression</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns>数据列表</returns>
        Task<List<TResult>> QueryAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">whereExpression</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns>数据列表</returns>
        List<TResult> Query<TResult>(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <param name="whereExpression">whereExpression</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns>数据列表</returns>
        Task<List<TResult>> QueryAsync<TResult>(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        List<TResult> Query<TResult>(Expression<Func<TEntity, TResult>> expression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        Task<List<TResult>> QueryAsync<TResult>(Expression<Func<TEntity, TResult>> expression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        List<TResult> Query<TResult>(string tableName, Expression<Func<TEntity, TResult>> expression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        Task<List<TResult>> QueryAsync<TResult>(string tableName, Expression<Func<TEntity, TResult>> expression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="whereExpression">过滤条件</param>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        List<TResult> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="whereExpression">过滤条件</param>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        Task<List<TResult>> QueryAsync<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="whereExpression">过滤条件</param>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        List<TResult> Query<TResult>(string tableName, Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 按照特定列查询数据列表带条件排序
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <typeparam name="TResult">返回指定结构数据实体</typeparam>
        /// <param name="whereExpression">过滤条件</param>
        /// <param name="expression">查询实体条件</param>
        /// <param name="strOrderByFileds">排序条件</param>
        /// <returns></returns>
        Task<List<TResult>> QueryAsync<TResult>(string tableName, Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="whereExpression"></param>
        /// <param name="orderByExpression"></param>
        /// <param name="isAsc"></param>
        /// <returns></returns>
        List<TEntity> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="whereExpression"></param>
        /// <param name="orderByExpression"></param>
        /// <param name="isAsc"></param>
        /// <returns></returns>
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string tableName, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression"></param>
        /// <param name="orderByExpression"></param>
        /// <param name="isAsc"></param>
        /// <returns></returns>
        List<TEntity> Query(string tableName, Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="orderByExpression">排序字段</param>
        /// <param name="isAsc"></param>
        /// <returns></returns>
        Task<List<TEntity>> QueryAsync(string tableName, Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string strWhere, string strOrderByFileds);

        /// <summary>
        /// 查询一个列表
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string strWhere, string strOrderByFileds);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>泛型集合</returns>
        List<TEntity> QuerySql(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>泛型集合</returns>
        Task<List<TEntity>> QuerySqlAsync(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>DataTable</returns>
        DataTable QueryTable(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        /// 根据sql语句查询
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>DataTable</returns>
        Task<DataTable> QueryTableAsync(string strSql, SugarParameter[] parameters = null);

        /// <summary>
        ///查询-2多表查询返回数据列表
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体2</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <returns>值</returns>
        List<TResult> QueryMuch<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null) where T : class, new();

        /// <summary>
        ///查询-2多表查询返回数据列表
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体2</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <returns>值</returns>
        Task<List<TResult>> QueryMuchAsync<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null) where T : class, new();

        ///  <summary>
        /// 查询-2多表查询返回数据列表
        ///  </summary>
        ///  <typeparam name="T">实体1</typeparam>
        ///  <typeparam name="T2">实体2</typeparam>
        ///  <typeparam name="TResult">返回对象</typeparam>
        ///  <param name="tableName">表名称</param>
        ///  <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        ///  <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        ///  <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        ///  <param name="strOrderByFileds">排序字段</param>
        ///  <returns>值</returns>
        List<TResult> QueryMuch<T, T2, TResult>(string tableName, Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null, string strOrderByFileds = null) where T : class, new();

        ///  <summary>
        /// 查询-2多表查询返回数据列表
        ///  </summary>
        ///  <typeparam name="T">实体1</typeparam>
        ///  <typeparam name="T2">实体2</typeparam>
        ///  <typeparam name="TResult">返回对象</typeparam>
        ///  <param name="tableName">表名称</param>
        ///  <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        ///  <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        ///  <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        ///  <param name="strOrderByFileds">排序字段</param>
        ///  <returns>值</returns>
        Task<List<TResult>> QueryMuchAsync<T, T2, TResult>(string tableName, Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null, string strOrderByFileds = null) where T : class, new();

        /// <summary>
        ///查询-3表查询返回数据列表
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体2</typeparam>
        /// <typeparam name="T3">实体3</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <returns>值</returns>
        List<TResult> QueryMuch<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new();

        /// <summary>
        ///查询-3表查询返回数据列表
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体2</typeparam>
        /// <typeparam name="T3">实体3</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <returns>值</returns>
        Task<List<TResult>> QueryMuchAsync<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new();

        /// <summary>
        ///查询-4表查询返回数据列表
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体2</typeparam>
        /// <typeparam name="T3">实体3</typeparam>
        /// <typeparam name="T4">实体3</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <returns>值</returns>
        List<TResult> QueryMuch<T, T2, T3, T4, TResult>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression, Expression<Func<T, T2, T3, T4, TResult>> selectExpression, Expression<Func<T, T2, T3, T4, bool>> whereLambda = null, string strOrderByFileds = null) where T : class, new();

        #endregion 查询列表

        #region 查询前N条数据

        /// <summary>
        /// 功能描述:查询前N条数据
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intTop">前N条</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);

        /// <summary>
        /// 功能描述:查询前N条数据
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intTop">前N条</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);

        /// <summary>
        /// 功能描述:查询前N条数据
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intTop">前N条</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string tableName, Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);

        /// <summary>
        /// 功能描述:查询前N条数据
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intTop">前N条</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string tableName, Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);

        /// <summary>
        /// 功能描述:查询前N条数据
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <param name="intTop">前N条</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string strWhere, int intTop, string strOrderByFileds);

        /// <summary>
        /// 功能描述:查询前N条数据
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <param name="intTop">前N条</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string strWhere, int intTop, string strOrderByFileds);

        #endregion 查询前N条数据

        #region 单表分页查询(未返回数据总行数及总页数)

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string tableName, Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string tableName, Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="strWhere">条件</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        List<TEntity> Query(string tableName, string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="strWhere">条件</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns>数据列表</returns>
        Task<List<TEntity>> QueryAsync(string tableName, string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);

        #endregion 单表分页查询(未返回数据总行数及总页数)

        #region 单表分页查询(有返回数据总行数及总页数)

        /// <summary>
        /// 分页查询[使用版本]
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns></returns>
        Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 分页查询[使用版本]
        /// </summary>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<TResult>(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 分页查询[使用版本]
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns></returns>
        Task<PageModel<TEntity>> QueryPage(string tableName, Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 分页查询[使用版本]
        /// </summary>
        /// <typeparam name="TResult">返回结果实体</typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<TResult>(string tableName, Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 分页查询[使用版本]
        /// </summary>
        /// <typeparam name="ids">id数组</typeparam>
        /// <typeparam name="TResult">返回结果实体</typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="whereExpression">条件表达式</param>
        /// <param name="intPageIndex">页码（下标0）</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段，如name asc,age desc</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<TResult>(int[] ids, string baseTableName, Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        #endregion 单表分页查询(有返回数据总行数及总页数)

        #region 多表分页查询

        /// <summary>
        /// 查询-2表查询分页
        /// </summary>
        /// <typeparam name="T">表1</typeparam>
        /// <typeparam name="T2">表2</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <param name="intPageIndex">分页索引</param>
        /// <param name="intPageSize">每页数量</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 查询-2表查询分页
        /// </summary>
        /// <typeparam name="T">表1</typeparam>
        /// <typeparam name="T2">表2</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="tableName">表名称</param>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <param name="intPageIndex">分页索引</param>
        /// <param name="intPageSize">每页数量</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<T, T2, TResult>(string tableName, Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<T, T2, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 查询-3表查询分页
        /// </summary>
        /// <typeparam name="T">表1</typeparam>
        /// <typeparam name="T2">表2</typeparam>
        /// <typeparam name="T3">表3</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <param name="intPageIndex">分页索引</param>
        /// <param name="intPageSize">每页数量</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 查询-4表查询分页
        /// </summary>
        /// <typeparam name="T">表1</typeparam>
        /// <typeparam name="T2">表2</typeparam>
        /// <typeparam name="T3">表3</typeparam>
        /// <typeparam name="T4">表4</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
        /// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
        /// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
        /// <param name="intPageIndex">分页索引</param>
        /// <param name="intPageSize">每页数量</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<T, T2, T3, T4, TResult>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
           Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
           Expression<Func<T, T2, T3, T4, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        /// <summary>
        /// 两表联合查询-分页-分组
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体1</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式</param>
        /// <param name="selectExpression">返回表达式</param>
        /// <param name="whereExpression">查询表达式</param>
        /// <param name="groupExpression">分组表达式</param>
        /// <param name="intPageIndex">页码</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryTabsPage<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<TResult, bool>> whereExpression, Expression<Func<T, object>> groupExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);

        #endregion 多表分页查询
    }
}